<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');
if($_POST['submit']=='删除'){
	if(empty($_POST["cbid"])) show_automsg('请先选择要删除的记录！',$GLOBALARR['curl'],1);
	$u_id=implode(",",$_POST["cbid"]);

	$db->sitedbexec("delete from ld_daili where id in($u_id) ");

	record_log('删除临时会员');
	show_automsg('删除成功！',$GLOBALARR['curl']);
}
if($_POST['submit']=='审核通过'){
	if(empty($_POST["cbid"])) show_automsg('请先选择记录！',$GLOBALARR['curl'],1);
	$u_id=implode(",",$_POST["cbid"]);

	$db->sitedbexec("update ld_daili set status=1,cross_time=".time()." where id in($u_id) ");

	record_log('申请代理审核通过');
	show_automsg('审核通过成功！',$GLOBALARR['curl']);
}
if($_POST['submit']=='审核不通过'){
	if(empty($_POST["cbid"])) show_automsg('请先选择记录！',$GLOBALARR['curl'],1);
	$u_id=implode(",",$_POST["cbid"]);

	$db->sitedbexec("update ld_daili set status=2 where id in($u_id) ");

	record_log('申请代理审核未通过');
	show_automsg('审核不通过成功！！',$GLOBALARR['curl']);
}

$pagecount=getnums($_GET["pagecount"],$GLOBALARR['pagecount']);
$option=getnums($_GET['option'],1);
$orderby=getnums($_GET['orderby'],1);
$quser=trim($_GET['quser']);

$tmp_arr['toption'].='<input type="submit" name="submit"   onclick="return boxcheck(\'没有选择要操作的数据\',\'您确定选中会员通过审核?\',\'正在执行中,请耐心等待！\');"  value="审核通过" class="thabtn">
		<input type="submit" name="submit"   onclick="return boxcheck(\'没有选择要操作的数据\',\'您确定选中会员通过审核?\',\'正在执行中,请耐心等待！\');"  value="审核不通过" class="thabtn"><input type="submit" name="submit"   onclick="return boxcheck(\'请先选择要删除的记录\',\'您确定要删除吗?\',\'删除正在执行中,请耐心等待！\');"  value="删除" class="thabtn"><a href="'.getqueurl('option',1).'" class="'.geteqval(array($option,1,'taselbtn','thabtn')).'">今日新增未审核</a><a href="'.getqueurl('option',2).'" class="'.geteqval(array($option,2,'taselbtn','thabtn')).'">所有未审核</a><a href="'.getqueurl('option',3).'" class="'.geteqval(array($option,3,'taselbtn','thabtn')).'">所有申请</a>';

$tmp_arr['torderby']='<a href="'.getqueurl('orderby',geteqval(array($orderby,1,'2','1'))).'" class="'.((strstr($orderby,'1')||strstr($orderby,'2'))?"tpaixusel":"tpaixu").'">'.geteqval(array($orderby,1,'时间↓','时间↑')).'</a>';

if(is_array($GLOBALARR['jjname'])){
foreach ($GLOBALARR['jjname'] as $k => $v) {
	$tmp_arr['tcolor'].='<a href="javascript:;" class="theacolor levelcolor'.$k.'">'.$v.'</a>';
}
}



$condition=' where 1=1 ';

if($quser){
	$condition.=" and uname like '%".$quser."%'";
}
if($option==1) $condition.=" and from_unixtime(dltime,'%Y-%m-%d')='".date('Y-m-d')."' and status=0 ";
if($option==2) $condition.=" and status=0 ";
if($option==3) $condition.=" ";

$order='';
if($orderby==1) $order=' order by a.id desc';
if($orderby==2) $order=' order by a.id asc';


$tmp_arr['tth']='<th><input type="checkbox" onclick="javascript:checkall(\'cbid[]\')"></th><th>序号</th><th>会员账号</th><th>姓名</th><th>申请省份</th><th>申请时间</th><th>状态</th>';

$psql="select count(0) from ld_daili $condition";
$db->query($psql,3);
$pcount=$db->fval;
$pagecount=$pagecount;   //每页条数 
$astr="&lsaction=dailiaudit&pagecount=$pagecount&orderby=$orderby&option=$option&quser=$quser";	  //Url
$pagearr=pagelist($pagecount,$pcount,$astr);
$offset=$pagearr[1];

$sql="select a.*,province from ld_daili as a left join ld_province as b on dl_pid=provinceid  $condition $order limit $offset,$pagecount";

$db->query($sql);
$ii=0;
foreach ($db->rs as $k => $v) {
	$ii++;
	$serialid=($pagearr[2]-1)*$pagecount+$ii;
	$rm=$member->getum($v['dluname'],'real_name,phone');
	if($v['status']==0){
		$status='未审核';
	}elseif($v['status']==1){
		$status='审核通过';
	}else{
		$status='未通过审核';
	}
	$tmp_arr['ttr'].='<tr class="levelcolor'.$v['user_level'].'">
						<td><input type="checkbox" name="cbid[]" value="'.$v['id'].'"></td>
						<td><span  title="'.$v["id"].'">'.$serialid.'</span></td>
						<td>'.$v['dluname'].'</td>
						<td>'.$rm['real_name'].'</td>
						<td>'.$v['province'].'</td>
						<td>'.date("Y-m-d H:i:s",$v['dltime']).'</td>
						<td>'.$status.'</td>
						</tr>';
}
$tmp_arr['tcount']=$pcount;
$tmp_arr['ttitle']=getmenu($GLOBALARR['menu'],'temporarylist');
$tmp_arr['tpage']=$pagearr[0];
admin_two($tmp_arr);

?>